package org.phalanx.client.menus;

import org.phalanx.client.UI.PhalanxIconButton;
import org.phalanx.client.UI.swing.listeners.pButtonListener;
import org.phalanx.client.UI.swing.listeners.pButtonPressed;
import org.phalanx.client.mapeditor.PhalanxMapEditorPanel;

public class PhalanxSideToolBarAction implements pButtonListener {
	private PhalanxMapEditorPanel masterPanel;
	
	public PhalanxSideToolBarAction(PhalanxMapEditorPanel parentPanel){
		this.masterPanel = parentPanel;
	}

	public void actionPerformed(pButtonPressed p) {
		PhalanxIconButton pressedButton = (PhalanxIconButton)p.getComponent();
		
		if (pressedButton.getName().equals("selection")){
			setActionModeSelected();
		}
		else if (pressedButton.getName().equals("stamp")){
			setWriteModeSelected();
		}
		else if (pressedButton.getName().equals("remove")){
			setDeleteModeSelected();
		}
		else if (pressedButton.getName().equals("addbp")){
			masterPanel.setActionMode(PhalanxMapEditorPanel.BUILD_POINT_ADD_MODE);
		}
		else if (pressedButton.getName().equals("removebp")){
			masterPanel.setActionMode(PhalanxMapEditorPanel.BUILD_POINT_DEL_MODE);
		}
		else if (pressedButton.getName().equals("zoomin")) {
			masterPanel.setActionMode(PhalanxMapEditorPanel.ZOOM_IN_MODE);
		}
		else if (pressedButton.getName().equals("zoomout")) {
			masterPanel.setActionMode(PhalanxMapEditorPanel.ZOOM_OUT_MODE);
		}
		else if (pressedButton.getName().equals("nav")) {
			masterPanel.setActionMode(PhalanxMapEditorPanel.NAV_MODE);
		}
	}
	
	public void setActionModeSelected(){
		masterPanel.setActionMode(PhalanxMapEditorPanel.SELECTION_MODE);
	}
	
	public void setWriteModeSelected(){
		masterPanel.setActionMode(PhalanxMapEditorPanel.ADDTILE_MODE);
	}
	
	public void setDeleteModeSelected(){
		masterPanel.setActionMode(PhalanxMapEditorPanel.REMOVE_MODE);
	}
}
